1. Field of the Invention
The invention relates to computer graphics processing, and more particularly to the blending of pixels.
2. Related Art
In the course of rendering an image, two or more pixels are sometimes mapped to the same point on the display. Such pixels are referred to hereinafter as competing pixels. Competing pixels create a problem as to which pixel ought to be displayed, or whether the competing pixels ought to be blended in some manner.
If the pixels are to be blended, a further question arises as to the appropriate method of blending. In some cases, the problem of competing pixels can be resolved by data associated with the pixels. In some graphics systems, for example, pixels have an associated stencil bit which indicates whether the pixel ought to mask other competing pixels, or, conversely, whether the pixel ought to be masked by a competing pixel. A pixel may also have a Z value associated with it, which indicates the distance from the point of the pixel to the viewer. Given two competing pixels, if the first pixel has a lesser Z value than that of the second pixel, then it is meant to portray a point closer to the viewer than the second pixel. If the first pixel represents an opaque point, e.g., a point on an object through which the viewer cannot see, then the first pixel obscures the second point, and the latter is not displayed.
In other cases, stencil bits and Z values do not resolve the overlap of pixels. In some cases, the stencil bits of competing pixels may have the same value. Likewise, the Z values of the competing pixels may have the same value. Moreover, a given graphics system may not use such variables. In such situations, it may be desirable to blend the competing pixels in some manner. Where, for example, two graphics primitives such as text characters adjoin in the image plane in the course of rasterization, pixels at the edges of the two regions can overlap. Blending can make the edges appear smooth and natural.
A number of blending operations have been devised, producing different visual effects. In some blending operations, the corresponding color coordinates of the competing pixels are combined in linear fashion to yield a new set of color coordinates for display. The new red coordinate, for example would be a weighted sum of the red coordinates of the competing pixels. The new green and blue coordinates would likewise be linear sums of the green and blue coordinates of the competing pixels, respectively. In other blending operations, the new red coordinate is the minimum (or maximum) of the red coordinates of the competing pixels, and the new green and blue coordinates likewise. More common is the use of a weighting factor, often referred to as alpha, to control the amount of the competing red, green, and blue values to use. For example, to blend a new pixel over an old one, the fractional amount represented by the new alpha scales the new red, green and blue coordinates. The remainder amount, produced by subtracting the new alpha from 1.0, scales the old red, green, and blue coordinates. The two scaled colors are added, by component, to produce the replacement red, green, and blue coordinates.
In all current practices known to the inventor, a single blend function is used for all pixels unconditionally at any given time.
In any given application, however, one blending operation might be more desirable than another. In some situations, for example, a linear combination of color coordinates may be desired; in other situations, it may be more desirable to choose the maximum color coordinates from each competing pixel.
Given that several blending operations are possible, a problem arises as to how to make more than one blending operation available to an application. Moreover, if more than one blending operation is made available in a graphics processing system, an additional problem arises as to how choose the appropriate one. There is an opportunity to use a choice between blending operations that are based on a per-pixel factor other than a Z or stencil value to visualize a particular characteristic of a rendered image. Hence there is a need for a system and method for providing multiple blending operations to a graphics application, and for choosing a blending operation that will produce a desired visual effect.
The invention described herein is a method and system for controlling the blending of pixels using alpha values. The alpha value of a first pixel is compared to the alpha value of a second pixel. The results of the comparison are then used to choose one of two blending operations from among two or more possible blending operations that are made available. The chosen blending operation is then performed so as to produce a blended pixel. The output of the blending operation is referred to hereinafter as pixel display data and includes a set of color coordinates and an alpha value for the blended pixel. The pixel display data is then sent to a frame buffer.
The invention described herein has the feature of facilitating the blending of pixels that overlap.
The invention has the additional feature of being implementable in hardware, software, or a combination thereof.
The invention has the advantage of making two or more blending operations available for resolving pixel overlap.
The invention has the further advantage of using the alpha values of competing pixels to determine which blending operation to use.